<template>
  <!--  <el-button type="success" round @click="addEarthquakeVisible=true"  style="margin: 5px" icon="el-icon-plus">添加地震</el-button>-->
  <el-dialog
      v-model="customerEditVisible"
      title="客户信息"
      width="50%"
  >
    <el-form
        ref="form"
        :model="form"
        label-width="120px"
        label-position="top"
    >
      <el-form-item label="客户编号" prop="id">
        <el-input placeholder="系统自动生成，无需输入，不可更改" disabled type="text" v-model="form.id"></el-input>
      </el-form-item>
      <el-form-item label="客户姓名" prop="name">
        <el-input placeholder="请输入客户姓名" type="text" v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="联系方式" prop="phone">
        <el-input placeholder="请输入联系方式" type="number" v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item label="住址" prop="address">
        <el-input placeholder="请输入住址" type="text" v-model="form.address"></el-input>
      </el-form-item>
      <el-form-item style="text-align: center;">
        <el-button
            type="primary"
            @click="onSubmit"
        >
          确定
        </el-button>
        <el-button @click="customerEditVisible=false">
          取消
        </el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import {Select} from "@element-plus/icons-vue";
import {updateCustomerApi} from "@/axios/api/Customer";

export default {
  name: "CustomerEdit",
  components: {Select},
  data() {
    return {
      sexes: ["男", "女"],
      customerEditVisible: false,
      form: {
        id: '',
        name: '',
        phone: '',
        address: '',
        sex: ''
      },
    }
  },
  methods: {
    onSubmit() {
      const params = {
        id: this.form.id,
        name: this.form.name,
        phone: this.form.phone,
        address: this.form.address,
        sex: this.form.sex
      }
      updateCustomerApi(params).then().catch(err => {
      })
      this.customerEditVisible = false
    },
    updateCustomer(data) {
      this.form = data
      // this.customerEditVisible=false
    }
  }
}
</script>

<style scoped>

</style>
